<!--{include(pe_tpl('header.html'));}-->
<div class="content">
	<div class="now">{$nowpath}</div>
	<div class="pro_box">
		<div class="pro_left">
			<div id="duotu_html">
				<div class="proimg jqzoom MagnifierMain">
					<img src="{$info['product_logo']}" jqimg="{$info['product_logo']}" width="381" height="381" />
				</div>
				<div class="clear"></div>
				<span class="spe_leftBtn" style="display:none">&lt;</span>
				<span class="spe_rightBtn" style="display:none">&gt;</span>
				<!--{if(count($info['album_list'])):}-->
				<div class="spec-items"> 
					<ul>
					<!--{foreach($info['album_list'] as $k=>$v):}-->
					<li <!--{if($k==0):}-->class="on"<!--{endif;}-->><img src="{$v}" bigimg="{$v}" /></li>
					<!--{endforeach;}-->
					</ul>
				</div>
				<!--{endif;}-->
			</div>
			<div class="clear"></div>
			<a href="javascript:collect_btn('{$info['product_id']}');" class="sctj fl">收藏商品</a>
			<div class="mat10 fxlj fr">
				<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a></div>
				<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdUrl":"{pe_url('product-'.$info['product_id'].'?u='.$_s_user_id)}","bdMini":"2","bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
			</div>
			<div class="clear"></div>
		</div>
		<div class="fl proinfo">
			<h3>{$info['product_name']}</h3>
			<!--{if($info['huodong_id']):}-->
			<div class="hd_box">
				<span class="fl ico_hd">{$info['huodong_tag']}</span>
				<span class="fr font13">距离结束：<span id="huodong_time" endtime="{$info['huodong_etime']}"></span></span>
				<div class="clear"></div>
			</div>
			<!--{endif;}-->
			<div class="proinfo_box">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>原价</td>
					<td><s class="num">¥ <span id="product_ymoney">{$info['product_ymoney']}</span></s></td>
				</tr>
				<tr>
					<td width="50">价格</td>
					<td>
						<span class="jg_price">
							<span class="font18">¥</span>
							<span id="product_money">{$info['product_money']}</span>
						</span>
					</td>
				</tr>
				</table>
				<div class="pro_ewm"><img src="{pe_thumb(pe_qrcode(pe_nowurl()))}" /></div>
			</div>
			<div class="xl_box">
				<span class="xl_li">运费：<span id="product_wlmoney">包邮</span></span>
				<span class="xl_li">热销：{$info['product_sellnum']} 件</span>
				<span class="xl_li" style="border-right:0;">奖励：<span class="cgreen">{$info['product_point']}</span> 积分</span>
				<div class="clear"></div>
			</div>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="mat10">
			<!--{if(count($info['quan_list'])):}-->
			<tr>
				<td>领券</td>
				<td>
					<!--{foreach($info['quan_list'] as $v):}-->
					<a class="proyhq_bg" href="{pe_url('quan-'.$v['quan_id'])}" target="_blank">
						<span class="proyhq_l fl"></span>
						<span class="proyhq_m fl">满{$v['quan_limit']}减{$v['quan_money']}</span>
						<span class="proyhq_r fl"></span>
						<div class="clear"></div>
					</a>
					<!--{endforeach;}-->
				</td>
			</tr>
			<!--{endif;}-->
			<!--<tr>
				<td>评分</td>
				<td>
					<div class="fl mat2">{pe_comment($comment_star)}</div>
					<span class="fl mal5 corg">{$comment_star} 分</span>
					<span class="fl mal10 c888">{$info['product_commentnum']}人评价</span>
					<div class="clear"></div>
				</td>
			</tr>-->
			<!--{foreach($info['product_rule'] as $k=>$v):}-->
			<tr>
				<td><div class="mab5">{$v['name']}</div></td>
				<td>			
					<!--{foreach($v['list'] as $kk=>$vv):}-->
					<span class="prodata_span js_sku" data-pid="{$k}" data-id="{$kk}">{$vv['name']}</span>
					<!--{endforeach;}-->
				</td>
			</tr>
			<!--{endforeach;}-->
			<tr>
				<td width="60">数量</td>
				<td class="shuliang">
					<input type="hidden" name="product_guid" value="{$product_guid}" />
					<span class="img1" onclick="pe_numchange('product_num', '-', 1);"><i></i></span>
					<div class="shuliang_box"><input type="text" name="product_num" value="1" /></div>
					<span class="img2" onclick="pe_numchange('product_num', '+', 999999);"><i></i></span>
					<span class="fl c999 mal10 mat3 font12">库存<span id="product_num">{$info['product_num']}</span>件</span>
				</td>
			</tr>
			</table>
			<div class="pro_buy">
				<!--{if($info['product_state']==0):}-->
				<div class="jiagwc_1"><i></i>已下架</div>
				<!--{elseif($info['product_num']==0):}-->
				<div class="jiagwc_1"><i></i>已售罄</div>
				<!--{elseif($info['product_virtual']):}-->
				<a href="javascript:buy_btn('buy', '{$info['product_id']}');" class="fl ljgm">立即购买</a>
				<!--{else:}-->
				<a href="javascript:buy_btn('buy', '{$info['product_id']}');" class="fl ljgm">立即购买</a>
				<a href="javascript:buy_btn('add', '{$info['product_id']}');" class="fl jiagwc"><i></i>加入购物车</a>
				<div class="clear"></div>
				<!--{endif;}-->
			</div>
		</div>
		<div class="proview_tj">
			<div class="proview_tjtt">
				<i></i>
				<span>新品推荐</span>
			</div>
			<!--{foreach($product_newlist as $v):}-->
			<div class="mat10">
				<a href="{pe_url('product-'.$v['product_id'])}" title="{$v['product_name']}" target="_blank"><img src="{$pe['host_tpl']}image/pixel.gif" data-url="{$v['product_logo']}" title="{$v['product_name']}" width="180" height="180" class="js_imgload" /></a>
			</div>
			<p class="proview_tjname"><a href="{pe_url('product-'.$v['product_id'])}" title="{$v['product_name']}" target="_blank">{$v['product_name']}</a></p>
			<p class="money3">¥{$v['product_money']}</p>
			<div class="clear"></div>
			<!--{endforeach;}-->
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
	<div style="margin-top:20px;"></div>
	<div class="hot_box">
		<h3 class="hot_tt">热销排行</h3>
		<div class="hotlist">
			<!--{foreach($product_hotlist as $v):}-->
			<div class="mat20">
				<a href="{pe_url('product-'.$v['product_id'])}" title="{$v['product_name']}" target="_blank"><img src="{$pe['host_tpl']}image/pixel.gif" data-url="{$v['product_logo']}" title="{$v['product_name']}" width="180" height="180" class="js_imgload" /></a>
			</div>
			<p class="proview_tjname"><a href="{pe_url('product-'.$v['product_id'])}" title="{$v['product_name']}" target="_blank">{$v['product_name']}</a></p>
			<p class="money3 fl">¥{$v['product_money']}</p>
			<!--{if($v['product_sellnum']):}--><div class="c999 fr font12">已售{$v['product_sellnum']}件</div><!--{endif;}-->
			<div class="clear"></div>
			<!--{endforeach;}-->
		</div>
	</div>
	<div class="fr xiangqing">
		<div class="promenu" id="js_menu">
			<ul class="fl">
				<li class="sel"><a href="javascript:;">商品详情</a><i></i></li>
				<li><a href="javascript:;">用户评价 <span class="corg">({$info['product_commentnum']})</span></a><i></i></li>
				<li><a href="javascript:;">最新成交 <span class="corg">({$info['product_sellnum']})</span></a><i></i></li>
			</ul>
			<div class="clear"></div>
		</div>
		<!--详情 Start-->
		<div class="promain js_menuhtml">
			<!--{if($info['product_video']):}-->
			<div id="product_video" style="width:600px;height:450px;"></div>
			<!--{endif;}-->
			{$info['product_text']}
		</div>
		<!--详情 end-->
		<!--评论 Start-->
		<div class="promain js_menuhtml" id="js_comment" style="display:none">
			<script type="text/html" id="js_comment_tpl">
			<div class="plrate">
				<div class="plrate_l fl"><strong>{$comment_rate_hao}%</strong><p class="c888 mat3">好评率</p></div>
				<div class="plrate_m fl">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="60">好评</td>
						<td><div class="gd_box"><div class="gd_1" style="width:{{hao_rate*2}}px;"></div></div></td>
						<td width="50">{$comment_rate_hao}%</td>
					</tr>
					<tr>
						<td>中评</td>
						<td><div class="gd_box"><div style="width:{{zhong_rate*2}}px;"></div></div></td>
						<td>{$comment_rate_zhong}%</td>
					</tr>
					<tr>
						<td>差评</td>
						<td><div class="gd_box"><div style="width:{{cha_rate*2}}px;"></div></div></td>
						<td>{$comment_rate_cha}%</td>
					</tr>
					</table>
				</div>
				<div class="plrate_r">
					购买过该商品的用户可以进行评价
					<div class="mat8"><a href="{$pe['host']}user.php?mod=order&state=wpj" target="_blank">发表评价<span class="font12 normal mal5">{{point}}</span></a></div>
				</div>
				<div class="clear"></div>
			</div>
			<div class="plmenu" id="js_commentmenu">
				<a href="javascript:comment_list(1, 'all');" data-value="all" class="sel">全部评价({{all_num}})</a>
				<a href="javascript:comment_list(1, 'hao');" data-value="hao">好评({{hao_num}})</a>
				<a href="javascript:comment_list(1, 'zhong');" data-value="zhong">中评({{zhong_num}})</a>
				<a href="javascript:comment_list(1, 'cha');" data-value="cha">差评({{cha_num}})</a>
			</div>
			{{each list as v k}}
			<div class="pj_box">
				<div class="pj_tx"><img src="{{v.user_logo}}"><p>{{v.user_name}}</p></div>
				<div class="pj_r">
					<ul class="plmain_ul">
						<li>{{v.comment_star}}</li>
					</ul>
					<div class="pingjia font14">{{v.comment_text}}</div>
					<div class="pj_img">
						{{each v.comment_logo as vv kk}}
						<a href="javascript:;"><img src="{{vv.logo}}" /></a>
						{{/each}}
					</div>
					<div class="pj_bigimg"></div>
					<div class="c888">{{v.comment_atime}}</div>
					{{if v.comment_reply == 1}}
					<div class="mjhf">卖家回复：{{v.comment_reply_text}}</div>
					<div class="c888">{{v.comment_reply_time}}</div>
					{{/if}}
				</div>
				<div class="clear"></div>
			</div>
			{{/each}}
			<div class="fenye mat10">{{page}}<div class="clear"></div></div>					
			</script>
		</div>
		<!--评论 End-->
		<!--成交记录 Start-->
		<div class="promain js_menuhtml" style="display:none">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="buylog_box">
			<tr>
				<th width="60"></th>
				<th style="text-align:left">用户昵称</th>
				<th width="25%">交易时间</th>
			</tr>
			<!--{foreach($info['buylog_list'] as $v):}-->
			<tr>
				<td><img src="{$v['user_logo']}" class="tx" /></td>
				<td style="text-align:left">{$v['user_name']}</td>
				<td>{$v['buylog_atime']}</td>
			</tr>
			<!--{endforeach;}-->
			</table>
		</div>
		<!--成交记录 End-->
	</div>
</div>
<link type="text/css" rel="stylesheet" href="{$pe['host']}include/plugin/jqzoom/style.css" />
<script type="text/javascript" src="{$pe['host']}include/plugin/jqzoom/jquery.jqzoom.js"></script>
<link type="text/css" rel="stylesheet" href="{$pe['host']}include/plugin/duotu/duotu.css" />
<script type="text/javascript" src="{$pe['host']}include/plugin/duotu/duotu.js"></script>
<script type="text/javascript" src="{$pe['host']}include/plugin/ckplayer/ckplayer.js"></script>
<script type="text/javascript">
var product_guid = "{$info['product_guid']}";
var product_rule = {json_encode($info['product_rule'])};
var prodata_list = {json_encode($info['prodata_list'])};				
var prodata_sel = {json_encode($info['prodata_sel'])};
var menu_top = $("#js_menu").offset().top;
template.config('escape', false);
$(function(){
	<!--{if(count($album_list)):}-->
	MagnifierF("duotu_html");
	<!--{endif;}-->
	$(".jqzoom").jqueryzoom();
	$(":input[name='product_num']").keyup(function(){
		if (!$(this).val().match(/^[1-9]+[0-9]*$/)) $(this).val(1);
	})
	pe_jstime("#huodong_time", '{time()}', 'html');
	//标签切换
	$("#js_menu").find("li").click(function(){
		var num = $(this).index();
		$("#js_menu li").removeClass("sel").eq(num).addClass("sel");
		$(".js_menuhtml").hide().eq(num).show();
		if (num == 1) {
			comment_list(1, 'all');
		}
		else {
			$("body,html").animate({scrollTop:menu_top}, 800);	
		}
	})
	//评价切换
	$("#js_commentmenu").find("a").click(function(){
		$("#js_commentmenu").find("a").removeClass("sel");
		$(this).addClass("sel");
		comment_list(1, 'all');
	})
	//晒图预览
	$(".pj_img img").live("click", function(){
		var pj_bigimg = $(this).parents(".pj_img").next(".pj_bigimg");
		$(this).parents(".pj_img").find("img").removeClass("sel");
		if (pj_bigimg.find("img").attr("src") == $(this).attr("src")) {
			pj_bigimg.empty();
		}
		else {
			$(this).addClass("sel");
			pj_bigimg.html('<img src="'+$(this).attr("src")+'" />');
		}
	})
	//规格检测
	if (product_rule.length > 0) sku_check();
	$(".js_sku").click(function(){
		var pid = parseInt($(this).attr("data-pid"));
		var id = parseInt($(this).attr("data-id"));	
		if ($(this).hasClass("prodata_lock")) return;
		if ($(this).hasClass("prodata_sel")) {
			$(this).removeClass("prodata_sel");
			prodata_sel[pid] = '';
		}
		else {
			$(this).siblings(".js_sku").removeClass("prodata_sel");
			$(this).addClass("prodata_sel");
			prodata_sel[pid] = id;
		}
		product_guid = '';
		sku_check();
	})
	pe_get("{$pe['host']}index.php?mod=useraddr&act=wlmoney&id={$info['product_id']}", function(json){
		if (json.code == 1) $("#product_wlmoney").text(json.data.wlmoney);
	})
})
var videoObject = {
	container: '#product_video',//“#”代表容器的ID，“.”或“”代表容器的class
	variable: 'player',//该属性必需设置，值等于下面的new chplayer()的对象
	flashplayer:false,//如果强制使用flashplayer则设置成true
	poster:"{$info['product_logo']}",
	video:"{$pe['host']}{$info['product_video']}"//视频地址
};
var player=new ckplayer(videoObject);
//收藏商品
function collect_btn(id) {
	pe_get("{$pe['host']}index.php?mod=product&act=collect&id="+id, function(json){
		$("#js_collectnum").html('（' + json.data.num + '）');
	});
}
//评价翻页
function comment_list(page, star){
	pe_get("{$pe['host']}index.php?mod=comment&id={$product_id}&star="+star+"&page="+page, function(json){
		pe_jshtml('js_comment', json.data)
		$("#js_commentmenu").find("a").removeClass("sel");
		$("#js_commentmenu").find("a[data-value='"+star+"']").addClass("sel");
		$("body,html").animate({scrollTop:menu_top}, 800);	
	});
}
//立即购买/加入购物车按钮
function buy_btn(act, id) {
	pe_get("{$pe['host']}index.php?mod=cart&act="+act+"&id="+id+"&guid="+product_guid+"&num="+$(":input[name='product_num']").val(), function(json){
		if (json.code == 'nologin') {
			pe_open("{$pe['host']}user.php?mod=do&act=login&{pe_jump()}");
			return;		
		}
		if (json.code == 1) {
			if (act == 'buy') {
				pe_open("{$pe['host']}index.php?mod=order&act=add&id="+json.data.id);
			}
			else if (act == 'pintuan') {
				pe_open("{$pe['host']}index.php?mod=order&act=add_pintuan&ptid={$order_ptid}&id="+json.id);
			}
			else {
				$("#cart_num").html(json.data.cart_num);
				layer.open({
					type: 1,
					title: false,
					closeBtn: 1,
					id: 'order_add',
					content: '<div class="gw"><p>成功加入购物车！</p><a class="gw1" href="javascript:layer.closeAll();">再逛逛</a><a class="gw2" href="{pe_url("cart")}">去结算</a><div class="clear"></div></div>'
				});
			}
		}
	})
}

//规格检测
function sku_check() {
	for (var pid in product_rule) {
		//检测每一个选项是否有效
		for (var id in product_rule[pid].list) {
			var sel_arr = JSON.parse(JSON.stringify(prodata_sel));
			sel_arr[pid] = id;
			if (sku_check_num(sel_arr)) {
				$(".js_sku[data-pid='"+pid+"'][data-id='"+id+"']").removeClass("prodata_lock");
			}
			else {
				$(".js_sku[data-pid='"+pid+"'][data-id='"+id+"']").addClass("prodata_lock");			
			}
		}
	}
	//循环规格选中的有效列表
	for (var i in prodata_list) {
		//如果选中规格组合完成
		if (prodata_list[i]['product_ruleid'] == prodata_sel.join(';')) {
			product_guid = prodata_list[i]['product_guid'];
			$("#product_money").html(prodata_list[i]['product_money']);
			$("#product_ymoney").html(prodata_list[i]['product_ymoney']);
			$("#product_num").html(prodata_list[i]['product_num']);
			return;
		}
	}
}
//检测选中项是否有库存（后期改哪里都不用动这块算法 prodata_sel = [0,'',3]）
function sku_check_num(prodata_sel) {
	var sel_num = 0;
	for (var i in prodata_sel) {
		if (prodata_sel[i] !== '') sel_num++;
	}
	for (var i in prodata_list) {
		var match_num = 0;
		var product_ruleid = prodata_list[i]['product_ruleid'].split(';');
		for (var pid in prodata_sel) {
			if (product_ruleid[pid] == prodata_sel[pid] && prodata_list[i]['product_num'] > 0) match_num++;	
		}
		if (match_num == sel_num) {
			return true;
		}
	}
	return false;
}
</script>
<!--{include(pe_tpl('footer.html'));}-->